/**   
 * @Title: UserAvatarCommunicater.java 
 * @Package: com.esun.rabbit2.communicaters 
 * @Description: 获取用户头像
 * @Author: Miko baoz@500wan.com   
 * @Date: 2011-7-5 下午07:17:05  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Key;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: UserAvatarCommunicater
 * @Description: 获取用户头像
 * @Author: Miko baoz@500wan.com
 * @Date: 2011-7-5 下午07:17:05
 * 
 */
public class UserAvatarCommunicater extends ServerCommunicater {

	public boolean getAvatar(String conuser) {

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> hm = new HashMap<String, String>();

		hm.put(BussinessCode.PASER_MID, BussinessCode.MID_GETUSERICON);

		HashMap<String, String> hm1 = new HashMap<String, String>();
		hm1.put(Key.KEY_CONUSER, conuser);
		list.add(hm1);
		list.add(hm);

		try {
			super.getServerResponse(list, true);
			if (super.getState() == 100) {
				UserInfo.getUserInfo().setAvatarAdd(super.getListResult().get(0).get(Key.KEY_F_USERICON));
				return true;
			} else {
				return false;
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
			return false;
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
			return false;
		} catch (SAXException e) {
			e.printStackTrace();
			return false;
		}

	}

}
